package com.ruoyi.web.controller.car;

import java.util.List;

import com.ruoyi.system.service.ICarpeisongService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Carpeisong;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 车辆配送 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-07-16
 */
@Controller
@RequestMapping("/system/carpeisong")
public class CarpeisongController extends BaseController
{
    private String prefix = "system/carpeisong";
	
	@Autowired
	private ICarpeisongService carpeisongService;
	
	@RequiresPermissions("system:carpeisong:view")
	@GetMapping()
	public String carpeisong()
	{
	    return prefix + "/carpeisong";
	}
	
	/**
	 * 查询车辆配送列表
	 */
	@RequiresPermissions("system:carpeisong:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Carpeisong carpeisong)
	{
		startPage();
        List<Carpeisong> list = carpeisongService.selectCarpeisongList(carpeisong);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出车辆配送列表
	 */
	@RequiresPermissions("system:carpeisong:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Carpeisong carpeisong)
    {
    	List<Carpeisong> list = carpeisongService.selectCarpeisongList(carpeisong);
        ExcelUtil<Carpeisong> util = new ExcelUtil<Carpeisong>(Carpeisong.class);
        return util.exportExcel(list, "carpeisong");
    }
	
	/**
	 * 新增车辆配送
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存车辆配送
	 */
	@RequiresPermissions("system:carpeisong:add")
	@Log(title = "车辆配送", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Carpeisong carpeisong)
	{		
		return toAjax(carpeisongService.insertCarpeisong(carpeisong));
	}

	/**
	 * 修改车辆配送
	 */
	@GetMapping("/edit/{carpeisongId}")
	public String edit(@PathVariable("carpeisongId") Integer carpeisongId, ModelMap mmap)
	{
		Carpeisong carpeisong = carpeisongService.selectCarpeisongById(carpeisongId);
		mmap.put("carpeisong", carpeisong);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存车辆配送
	 */
	@RequiresPermissions("system:carpeisong:edit")
	@Log(title = "车辆配送", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Carpeisong carpeisong)
	{		
		return toAjax(carpeisongService.updateCarpeisong(carpeisong));
	}
	
	/**
	 * 删除车辆配送
	 */
	@RequiresPermissions("system:carpeisong:remove")
	@Log(title = "车辆配送", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(carpeisongService.deleteCarpeisongByIds(ids));
	}
	
}
